package it.com.cci.observer_pattern.java_api;

import java.util.Observable;//可观测者

/**
 * @author Lefnmg
 * @Description:
 * @date 2018/3/25
 */
public class WeatherData extends Observable {
    private float temperature;
    private float humidity;
    private float pressure;

    public WeatherData() {
    }
    public void measurementsChanged(){
        setChanged(); //设置 change = true
        notifyObservers();//if(change) 执行 此方法 推送数据给观察者
    }
    public void setMeasurements(float temperature,float humidity,float pressure){
        this.temperature = temperature;
        this.humidity = humidity;
        this.pressure = pressure;
        measurementsChanged();
    }
    //用于观察者拉取想要信息
    public float getHumidity() {
        return humidity;
    }

    public float getPressure() {
        return pressure;
    }

    public float getTemperature(){
        return temperature;
    }
}
